package com.kehutong.admin.entity.app;

import java.util.ArrayList;
import java.util.List;

import org.coraframework.json.annotation.JSONField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;
import org.coraframework.orm.util.IDType;

import com.kehutong.common.entity.ITree;

/**
 * 应用端菜单
 * 
 * @author liuzhen
 */
@Table(value="sys_menu_app", idType=IDType.TIMESTAMP)
public class AppMenu extends Entity implements ITree<AppMenu> {

	private static final long serialVersionUID = -2228530139210436493L;

	protected AppMenu(String id) {
		super(id);
	}

	@Column(comment = "上级菜单")
	private String pid;

	@Column(comment = "菜单名称")
	private String name;

	@Column(comment = "链接")
	private String href;

	@Column(comment = "目标（ inner、outter、mini）")
	private String target;

	@Column(comment = "图标")
	private String icon;

	@Column(comment = "权限标识")
	private String permission;

	@Column(defValue = "NOT NULL", comment = "排序")
	private Integer sort;

	@Column(comment = "是否显示")
	private boolean show;
	
	@Column(length=127, comment = "描述")
	private String remark;

	@JSONField(serialize = false)
	@Column(comment = "逻辑删除")
	private boolean deleted;

	@UnSave private List<AppMenu> childList;

	@Override
	public String getPid() {
		return pid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public boolean isShow() {
		return show;
	}

	public void setShow(boolean show) {
		this.show = show;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
	public List<AppMenu> getChildList() {
		return childList;
	}

	@Override
	public void setChildList(List<AppMenu> childList) {
		this.childList = childList;
	}

	@Override
	public void addChild(AppMenu child) {
		if (childList == null) {
			this.childList = new ArrayList<>();
		}
		this.childList.add(child);
	}
}
